package com.sc.nft.entity.vo.metaWalletDTO;

import cn.hutool.core.date.DateTime;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class SimpleUserCollectionVO {

    @ApiModelProperty("用户藏品id")
    private Long userCollectionId;

    @ApiModelProperty("藏品id")
    private Long collectionId;

    @ApiModelProperty("藏品编号")
    private String collectionNumber;

    @ApiModelProperty("买入价")
    private String buyPrice;

    @ApiModelProperty("锁仓到期日期")
    @JsonIgnore
    private Date lockedPositionTime;

    @ApiModelProperty("是否锁仓")
    private Boolean isLockedPosition=Boolean.FALSE;

    public void setBuyPrice(BigDecimal buyPrice) {
        this.buyPrice = buyPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setLockedPositionTime(Date lockedPositionTime) {
        this.lockedPositionTime=lockedPositionTime;
        // 当前日期大于锁仓日期,那么就是已经到期了 是否锁仓字段给false.如果小于的话,给true.并且说明 锁仓到期时间
        if (lockedPositionTime != null) {
            if (this.lockedPositionTime.getTime() < DateTime.now().getTime()) {
                this.isLockedPosition = false;
            } else {
                this.isLockedPosition = true;
            }
        } else {
            this.isLockedPosition = false;
        }
    }
}
